package com.ruoyi.api.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzLiulan;
import com.ruoyi.system.service.IDzLiulanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 浏览历史Controller
 * 
 * @author ruoyi
 * @date 2023-09-26
 */
@RestController
@RequestMapping("/api/liulan")
public class DzLiulanApiController extends BaseController
{
    @Autowired
    private IDzLiulanService dzLiulanService;

    /**
     * 查询浏览历史列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzLiulan dzLiulan)
    {
        startPage();
        List<DzLiulan> list = dzLiulanService.selectDzLiulanListWeb(dzLiulan);
        return getDataTable(list);
    }

    /**
     * 导出浏览历史列表
     */
    @Log(title = "浏览历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzLiulan dzLiulan)
    {
        List<DzLiulan> list = dzLiulanService.selectDzLiulanListWeb(dzLiulan);
        ExcelUtil<DzLiulan> util = new ExcelUtil<DzLiulan>(DzLiulan.class);
        util.exportExcel(response, list, "浏览历史数据");
    }

    /**
     * 获取浏览历史详细信息
     */
    @GetMapping(value = "/{llId}")
    public AjaxResult getInfo(@PathVariable("llId") Long llId)
    {
        return AjaxResult.success(dzLiulanService.selectDzLiulanByLlId(llId));
    }

    /**
     * 新增浏览历史
     */
    @Log(title = "浏览历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzLiulan dzLiulan)
    {
        return toAjax(dzLiulanService.insertDzLiulan(dzLiulan));
    }

    /**
     * 修改浏览历史
     */
    @Log(title = "浏览历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzLiulan dzLiulan)
    {
        return toAjax(dzLiulanService.updateDzLiulan(dzLiulan));
    }

    /**
     * 删除浏览历史
     */
    @Log(title = "浏览历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{llIds}")
    public AjaxResult remove(@PathVariable Long[] llIds)
    {
        return toAjax(dzLiulanService.deleteDzLiulanByLlIds(llIds));
    }
}
